package br.com.millenium.service.cliente.processaction;

import br.com.millenium.domain.manager.MilleniumManagerFactory;
import lumis.doui.processaction.ProcessActionHandler;
import lumis.portal.PortalException;

@SuppressWarnings("rawtypes")
public class CheckDuplicateOSProcessActionHandler extends ProcessActionHandler
{
	@Override
	public void processAction() throws PortalException 
	{
		String osNumero = (String)getParameter( "numeroOs" );
		String osFilial = (String)getParameter( "filialId" );
		String osEquipe = (String)getParameter( "equipeId" );
		String osId     = (String)(getParameter( "id" ) == null ? "" : getParameter( "id" ));
		
		if( MilleniumManagerFactory.getClienteManager().isDuplicateOSFilial(osId, osNumero, osFilial, transaction) )
			throw new PortalException( "STR_OS_FILIAL_EXISTS;", getResource() );
		else if( MilleniumManagerFactory.getClienteManager().isDuplicateOSEquipe(osId, osNumero, osEquipe, transaction) )
			throw new PortalException( "STR_OS_EQUIPE_EXISTS;", getResource() );
	}
}
